<template>
  <div class="body">
    <su-header @family="family" :productFamily="productFamily" />
    <su-carousel class="su_carousel" :ca_item="carousel" />
    <div class="apprec">
      <p class="appre">珍品赏析</p>
      <index-product-item :product="productIndex" />
    </div>
    <!-- 为你推荐 -->
    <div class="rec">
      <p class="recForU">为您推荐</p>
      <index-nav />
    </div>
  </div>
</template>

<script>
import IndexNav from "../components/IndexNav.vue";
import IndexProductItem from "../components/IndexProductItem.vue";
import SuCarousel from "../components/SuCarousel.vue";
import SuHeader from "../components/SuHeader.vue";
export default {
  components: { SuHeader, SuCarousel, IndexProductItem, IndexNav },
  data() {
    return {
      productFamily: [],
      carousel: [],
      productIndex: [],
    };
  },
  methods: {
    getData() {
      const url = "v4/index/product";
      this.axios.get(url).then((res) => {
        this.productFamily = res.data.productFamily;
        this.carousel = res.data.carouselItem;
        this.productIndex = res.data.ProductIndex;
      });
    },
    // 自定义事件方法接收搜索后的结果
    family(value){
        this.productIndex=value
    }
  },
  mounted() {
    this.getData();
  },
};
</script>

<style lang="scss" scoped>
.body {
  background-color: #eee;
}
.su_carousel {
  margin-top: 3.4em;
}
.rec {
  background-color: rgb(254, 254, 254);
  margin-top: 0.6em;
  padding-top: 0.5em;
  .recForU {
    font-weight: bold;
    color: rgb(120, 120, 120);
    width: 10em;
    height: 2em;
    line-height: 2em;
    padding-left: 0.8em;
    margin-bottom: 0.5em;
  }
}
.apprec {
  background-color: rgb(254, 254, 254);
  margin-top: 0.6em;
  padding-top: 0.5em;
  .appre {
    font-weight: bold;
    color: rgb(120, 120, 120);
    width: 10em;
    height: 2em;
    line-height: 2em;
    padding-left: 0.8em;
    margin-bottom: 0.5em;
  }
}
</style>